﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows;

namespace SymmetricEncription.Presenters
{
    public abstract class ProcessStepBase : INotifyPropertyChanged
    {
        protected ProcessStepBase previousStep;
        public ProcessStepBase PreviousStep
        {
            get { return previousStep; }
        }

        protected ProcessStepBase nextStep;
        public virtual ProcessStepBase GetNextStep()
        {
            return this.nextStep;
        }

        private string title = "Обработка";
        public string Title
        {
            get { return title; }
            set
            {
                if (title != value)
                {
                    title = value;
                    RaisePropertyChanged("Title");
                }
            }
        }

        public ProcessStepBase(ProcessStepBase previousStep, bool assignAsNext = true)
        {
            this.previousStep = previousStep;
            if (assignAsNext && previousStep != null)
            {
                previousStep.nextStep = this;
            }
        }

        public bool CanGoBack
        {
            get { return this.previousStep != null; }
        }
        public virtual bool CanGoNext
        {
            get { return true; }
        }

        public abstract UIElement StepUIControl { get; }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;
        protected void RaisePropertyChanged(string propName)
        {
            var handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propName));
            }
        }

        #endregion
    }
}
